// div top-2 后台时间
function get_top2_time(){
	$.ajax({
		url:"/time",
		timeout:10000,  // 超时时间 10s
		success:function(data){
			$("#top-2").html(data)
		},
		error: function(xhr, type, errThrown){

		}
	});
}


// div mid-1 简略总计
function get_mid1_data(){
	$.ajax({
		url:"/mid1",
		success:function(mid1_data){
			$(".num h2").eq(0).text(mid1_data.confiirm);
			$(".num h2").eq(1).text(mid1_data.suspect);
			$(".num h2").eq(2).text(mid1_data.heal);
			$(".num h2").eq(3).text(mid1_data.dead);
		},
		error: function(xhr, type, errThrown){
			
		}
	});
}

// div mid-2 各省数据
function get_mid2_data() {
	$.ajax({
		url:"/mid2",
		success:function(mid2_data){
			ec_center_option.series[0].data = mid2_data.data
			ec_center.setOption(ec_center_option)
		},
		error: function(xhr, type, errThrown){
			
		}
	});
}

// div left-1 累计趋势

function get_left1_data(){
	$.ajax({
		url: "/left1",
		success: function(left1_data) {
			ec_left1_Option.xAxis[0].data=left1_data.day
			
			ec_left1_Option.series[0].data=left1_data.confirm
			ec_left1_Option.series[1].data=left1_data.suspect
			ec_left1_Option.series[2].data=left1_data.heal
			ec_left1_Option.series[3].data=left1_data.dead
			ec_left1.setOption(ec_left1_Option)
			
			
		},
		error: function(xhr, type, errThrown){
			
		}
	});
}

// div left-2 新增趋势

function get_left2_data(){
	$.ajax({
		url: "/left2",
		success: function(left2_data) {
			ec_left2_Option.xAxis[0].data=left2_data.day
			
			ec_left2_Option.series[0].data=left2_data.confirm_add
			ec_left2_Option.series[1].data=left2_data.suspect_add
			ec_left2_Option.series[2].data=left2_data.heal_add
			ec_left2_Option.series[3].data=left2_data.dead_add
			
			ec_left2.setOption(ec_left2_Option)
			
			
		},
		error: function(xhr, type, errThrown){
			
		}
	});
}


// div right-1 Top5

function get_right1_data(){
	$.ajax({
		url: "/right1",
		success: function(right1_data) {

			ec_right1_Option.xAxis.data=right1_data.city
			
			ec_right1_Option.series[0].data=right1_data.confirm
			
			ec_right1.setOption(ec_right1_Option)
			
			
		},
		error: function(xhr, type, errThrown){
			
		}
	});
}

// div right-2 词云

function get_right2_data(){
	$.ajax({
		url: "/right2",
		success: function(right2_data) {

			ec_right2_Option.series[0].data=right2_data.kws
			
			ec_right2.setOption(ec_right2_Option)
			
			
		},
		error: function(xhr, type, errThrown){
			
		}
	});
}
// setInterval(gettime, 1000)  // 一秒钟执行一次
// setInterval(get_mid1_data, 1000)
// setInterval(get_mid2_data, 1000)


get_top2_time()

get_mid1_data()
get_mid2_data()

get_left1_data()
get_left2_data()

get_right1_data()
get_right2_data()

// 刷新频率
setInterval(get_top2_time, 1000)
setInterval(get_right2_data, 1000*10)










